package com.test2015.ui.button;

import java.awt.Container;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class IconBtn extends JFrame{
	private String btnpic = "com/test2015/ui/button/res2/login_button.png";
	private String btnrolloverpic = "com/test2015/ui/button/res2/login_button_rover.png";
	private String btnpressedpic = "com/test2015/ui/button/res2/login_button_pressed.png";
	
	int w = 332;
	int h = 60;
	
	public IconBtn(){
		JPanel jPanel = new JPanel();
		jPanel.setLayout(null);
		Container contentPane = this.getContentPane();
		contentPane.add(jPanel);
		
		JButton createIconBtn = createIconBtn(btnpic, btnrolloverpic, btnpressedpic);
		jPanel.add(createIconBtn);
		createIconBtn.setBounds(10, 10, w, h);
		
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		this.setSize(400, 300);
		this.setLocationRelativeTo(null);
		this.setVisible(true);
	}
	
	public static JButton createIconBtn(String iconPath,String rolloverIcon,String pressedIcon){
		JButton btn = new JButton("");
		
		Icon buttonIcon = new ImageIcon(ClassLoader.getSystemResource(iconPath));
		Icon buttonRoverIcon = new ImageIcon(ClassLoader.getSystemResource(rolloverIcon));
		Icon buttonPressedIcon = new ImageIcon(ClassLoader.getSystemResource(pressedIcon));
		
		btn.setBorder(null);
		btn.setMargin(null);
		btn.setOpaque(false);
		btn.setIcon(buttonIcon);
		btn.setRolloverEnabled(true);
		btn.setRolloverIcon(buttonRoverIcon);
		btn.setPressedIcon(buttonPressedIcon);
		btn.setContentAreaFilled(false);
		btn.setRequestFocusEnabled(false);
		
		return btn;
	}
	
	
	public static void main(String[] args) {
		new IconBtn();
	}
	
}	
